﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Input;
using AvalonDock;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Win32;
using RanbuOM.SSF4.BCM;
using RanbuOM.Serialization;

namespace RanbuUI
{
    public class MainWindowViewModel 
    {
        public ObservableCollection<AvalonDock.DocumentContent> Documents { get; private set; }

        public ICommand CreateDummyDocCommand { get; private set; }

        public MainWindowViewModel()
        {
            this.Documents = new ObservableCollection<DocumentContent>();
            this.CreateDummyDocCommand = new DelegateCommand(CreateDummyDoc);
        }

        private void CreateDummyDoc()
        {
            this.Documents.Add(new DocumentContent {Title = "Dummy", Content = "Dummy" });
        }

        public void OpenBCM(string file)
        {
            using (var reader = new RanbuReader(file))
            {
                var bcm = reader.ReadDataFile<BcmFile>();
                var grid = new DataGridEx { DataContext= bcm.Moves };
                this.Documents.Add(new DocumentContent { Title = Path.GetFileName(file), Content = grid });
            }
        }
    }
}
